package com.sgb.kjwl.view.ui.activity.leaseAsk;

import android.content.Context;
import android.content.Intent;
import androidx.databinding.DataBindingUtil;
import android.view.View;

import com.sgb.kjwl.AppActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ActivityMachineInBinding;
import com.sgb.kjwl.di.machine.DaggerMachineComponent;
import com.sgb.kjwl.di.machine.MachineModule;
import com.sgb.kjwl.model.entity.MachineRentInEntity;
import com.sgb.kjwl.viewmodel.machine.MachineInModel;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.util.DialogUtil;
import com.swgk.core.util.MDateUtil;

import javax.inject.Inject;
@Deprecated
public class MachineInActivity extends AppActivity {

    private ActivityMachineInBinding binding;
    @Inject
    MachineInModel viewModel;
    private MachineRentInEntity data;

    @Override
    protected void setupActivityComponent(AppComponent appComponent) {
        DaggerMachineComponent.builder().appComponent(appComponent).machineModule(new MachineModule(this)).build().inject(this);
    }

    public static void start(Context context, String id) {
        Intent intent = new Intent();
        intent.putExtra("id", id);
        intent.setClass(context, MachineInActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void init() {
        viewModel.getInDetail(getIntent().getStringExtra("id"));
    }

    @Override
    protected void initView() {
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_machine_in);
        binding.ivBack.setOnClickListener(this);
        binding.tvCallContact.setOnClickListener(this);
        binding.tvCallSgb.setOnClickListener(this);

    }

    public void showDetail(MachineRentInEntity data) {
        this.data = data;
        binding.tvTitle.setText(data.getTitle());
        binding.tvUpdate.setText(MDateUtil.getDate(data.getUpdateTime()));
        binding.tvPaymentType.setText("协商付款");
        binding.tvNum.setText("数量：" + data.getNum() + "台");
        binding.tvLocate.setText(data.getSecondJobArea() + data.getThreeJobArea());
        binding.tvType.setText(data.getCategoryName());
        binding.tvDate.setText(data.getConstructionTime() + "天");
        binding.tvPaymentType.setText("面议");
        binding.tvInTime.setText(MDateUtil.getDate(data.getApproachTime()));
        binding.tvDetail.setText(data.getDescribe());
        binding.tvTelName1.setText(data.getContacts());
        binding.tvTel1.setText(data.getContactNumber());
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.tv_call_contact:
                DialogUtil.showTelDialog(this, data.getContacts(), data.getContactNumber());
                break;
            case R.id.tv_call_sgb:
                DialogUtil.showTelDialog(this, "客服电话", "4000010051");
                break;
        }
    }
}
